import Koa from "koa";
import router from "./router/index.js";
import { sync } from './db/index.js'
import { registerTemplate } from "./template/index.js";
import koaStatic from 'koa-static'
import bodyparser from 'koa-bodyparser'

const app = new Koa();  //实例化koa

app.use(bodyparser());  //解析json对象

app.use(registerTemplate());  //注册模板引擎

sync();  //连接数据库

app.use(koaStatic('./static'));  //处理静态资源中间件

app.use(router);   //使用路由中间间

app.use(async (ctx, next) => { })

//监听端口
app.listen(3000, () => {
   console.log("服务运行地址如下 \nhttp://localhost:3000");
})